package threadsafe;

public class AccountThread extends Thread{
    //两个线程共享同一账户对象
    private Account act;

    //通过构造方法传递过来账户对象
    public AccountThread(Account act){
        this.act = act;
    }

    @Override
    public void run() {
    //表示提款
        double money = 5000;
        act.withdraw(money);
        System.out.println(Thread.currentThread().getName() + "账户" + act.getActno() + "取款成功，余额：" + act.getBalance());
    }
}
